import React from 'react';
import {createStackNavigator} from '@react-navigation/stack';
import {NavigationContainer} from '@react-navigation/native';
import NavigationConfig from '../config/navigationConfig';

import NavigationUtil from '../utils/navigationUtil';

import hotSearchPage from '../pages/hotSearchPage/hotSearchPage';
import detailPage from '../pages/DetailPage/detailPage';

//创建初始化导航器
const Stack = createStackNavigator();
function CreateInitNavigation() {
  return (
    <Stack.Navigator>
      <Stack.Screen
        headerMode={'none'}
        name={'HomePage'}
        component={CreateMainNavigation}
        options={{
          headerShown: false, //隐藏头
        }}
      />
      <Stack.Screen name={'hotSearchPage'} component={hotSearchPage} />
      <Stack.Screen
        name={'detailPage'}
        component={detailPage}
        options={{
          headerBackTitleVisible: false,
          title: '详情',
          leftLabel: '',
        }}
      />
    </Stack.Navigator>
  );
}

//创建主控制器(普通)
function CreateMainNavigation() {
  return NavigationUtil.CreateMainNavigation(NavigationConfig.MainNavigation);
}

//创建主控制器(带颜色变化)
function CreateMaterialNavigation() {
  return NavigationUtil.CreateMaterialNavigation(
    NavigationConfig.MainNavigation,
  );
}

//创建顶部滑动栏
// function CreateMaterialTopTabNavigation() {
//   return NavigationUtil.CreateMaterialTopTabNavigator(
//     NavigationConfig.MainNavigation,
//   );
// }

export default function AppNavigation() {
  return (
    <NavigationContainer>
      <CreateInitNavigation />
    </NavigationContainer>
  );
}
